package com.tzl.design_pattern.observer_pattern.observer_pattern_in_jdk;

import java.util.Observable;
import java.util.Observer;

/**
 * 观察者,实现Observer类
 *
 * @author Zhilei Tang
 * @date Created in 2020/11/14 22:15
 */
public class Friends implements Observer {

  private String friendName;

  public String getFriendName() {
    return friendName;
  }

  public void setFriendName(String friendName) {
    this.friendName = friendName;
  }

  @Override
  public void update(Observable o, Object arg) {
    Trends trends = new Trends();
    if (arg instanceof Trends) {
      trends = (Trends) arg;
    }
    System.out.printf(
        "%s,您好! 您收到了来自%s的一条动态{%s},快去点赞吧!\n",
        getFriendName(), trends.getNickName(), trends.getContent());
  }
}
